using DaprDemo.Shared;
using Microsoft.AspNetCore.Mvc;

var app=WebApplication.Create(args);
app.MapPost("{method}", Calculate);
app.Run();

static IResult Calculate(string method, [FromBody]Input input)
{
    var result = method.ToLower() switch
    {
        "add" => input.X + input.Y,
        "sub" => input.X - input.Y,
        _ => throw new InvalidOperationException("invalid oper!")
    };

    return Results.Json(new Output { Result = result });
}